package com.examsage.examsage.controller;

import com.examsage.examsage.model.Course;
import com.examsage.examsage.model.vo.ResponseVO;
import com.examsage.examsage.service.ICourseService;
import com.examsage.examsage.service.IMajorApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author examsage
 * @since 2025-07-02
 */
@RestController
@RequestMapping("/api/v1/course")
public class CourseController {
    @Autowired
    private ICourseService courseService;

    @PostMapping("/")
    public ResponseVO addCourse(Course course) {
        return courseService.addCourse(course);
    }

    @GetMapping("/")
    public ResponseVO getCourseList(int page, int size, String courseName, String courseCode) {
        return courseService.getCourseList(page, size, courseName, courseCode);
    }

    @GetMapping("/{id}")
    public ResponseVO getCourseById(@PathVariable Long id) {
        return courseService.getCourseById(id);
    }

    @PutMapping("/{id}")
    public ResponseVO updateCourse(@PathVariable Long id, Course course) {
        return courseService.updateCourse(id, course);
    }

    @DeleteMapping("/{id}")
    public ResponseVO deleteCourse(@PathVariable Long id) {
        return courseService.deleteCourse(id);
    }
}
